#define  _CRT_SECURE_NO_WARNINGS

#include "list.h"

namespace yjz
{
	void test_list1()
	{
		list<int> lt;
		lt.push_back(1);
		lt.push_back(2);
		lt.push_back(3);
		lt.push_back(4);
		lt.push_back(5);

		list<int>::iterator it = lt.begin();
		while (it != lt.end())
		{
			cout << *it << " ";
			++it;
		}
		cout << endl;

		lt.erase(++lt.begin());
		lt.insert(--lt.end(), 10);
		for (auto e : lt)
		{
			cout << e << " ";
		}
		cout << endl;
	}

	void test_list2()
	{
		struct aa
		{
			int _a1 = 1;
			int _a2 = 2;
		};

		list<aa> lt;
		lt.push_back(aa());
		lt.push_back(aa());
		lt.push_back(aa());
		lt.push_back(aa());

		list<aa>::iterator it = lt.begin();
		while (it != lt.end())
		{
			//cout << *it << " ";
			cout << it->_a1 << " " << it->_a2 << " ";
			cout << it.operator->()->_a1 << " " << it.operator->()->_a2 << " ";
			++it;
		}
		cout << endl;
	}

	void test_list3()
	{
		list<int> lt1;
		lt1.push_back(1);
		lt1.push_back(2);
		lt1.push_back(3);
		lt1.push_back(4);

		list<int> lt2 = lt1;

		list<int>::iterator it = lt2.begin();
		while (it != lt2.end())
		{
			cout << *it << " ";
			++it;
		}
		cout << endl;

		list<int> lt3;
		lt3.push_back(10);
		lt3.push_back(20);
		lt3.push_back(30);
		lt3.push_back(40);
		
		lt2 = lt3;

		list<int>::iterator i = lt2.begin();
		while (i != lt2.end())
		{
			cout << *i << " ";
			++i;
		}
		cout << endl;
	}
}

int main()
{
	yjz::test_list3();
	return 0;
}
